package cn.app.android.sichuanxiaoke.com.xiaokeapp.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.app.android.sichuanxiaoke.com.xiaokeapp.R;
import cn.app.android.sichuanxiaoke.com.xiaokeapp.utils.ConstantUtils;

public class EnterMoneyNumberActivity extends AppCompatActivity {
    @BindView(R.id.tb)
    Toolbar tb;
    @BindView(R.id.moneyNumber)
    EditText money;
    private String admin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_enter_money_number);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        Intent intent = getIntent();
         admin = intent.getStringExtra("admin");
        tb.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @OnClick(R.id.submitButton)
    public void OnClick(View view){
        String mon = money.getText().toString();

        SubmitToServicer(admin,mon);
    }

    private void SubmitToServicer(String admin,String money) {
        //18696515408

        HttpParams params = new HttpParams();
        params.put("type","to_user");
        params.put("to_user",admin);
        params.put("amount",money);

        OkGo.<String>post(ConstantUtils.APP_INSIDE_TRANSFER_ACCOUNTS).params(params).execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {
                String body = response.body();
                Log.i("SubmitToServicer","  onSuccess--"+body);


            }

            @Override
            public void onError(Response<String> response) {

                String body = response.body();
                Log.i("SubmitToServicer","  onError--"+body);
            }
        });

    }
}
